package com.yuda.tools.checkanswer.mapper;

import com.yuda.tools.checkanswer.dto.LogAnswer;
import com.yuda.tools.checkanswer.dto.LogNotFound;
import com.yuda.tools.checkanswer.dto.SpartSubject;
import com.yuda.tools.checkanswer.dto.StudentLog;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.ResultType;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

public interface CheckLogMapper {

    //需要检查的日志记录
    List<StudentLog> listStudentsForLog(Integer paperId);

    List<StudentLog> listStudentsByStudentIdForLog(@Param("studentId") String studentId, @Param("paperId") Integer paperId);

    @Update("update log_student_paper set log_db_type = 1,log_area = #{maxTimeArea},log_time=#{logTime} where id =#{id}")
    void updateSpartaExamStudentLogStatus(@Param("maxTimeArea") String maxTimeArea, @Param("id") Integer id, @Param("logTime") String logTime);

    @Update("update sparta_change_student set log_db_type = 1,log_area = #{maxTimeArea},log_time=#{logTime} where id=#{id}")
    void updateSpartaChangeStudentLogStatus(@Param("maxTimeArea") String maxTimeArea, @Param("id") Integer id , @Param("logTime") String logTime);

    //有问题日志记录
    List<LogNotFound> listLogNotFind(LogNotFound logNotFound);

    @ResultType(SpartSubject.class)
    @Select("select id as subjectId, name from sparta_subject")
    List<SpartSubject> listSpartaSubject();

    @Select("select name from sparta_common_examroom where name like concat('%',#{key},'%')")
    List<String> searchCommonExamRoom(String key);

    void batchSaveAnswer(@Param("list") List<LogAnswer> list);
}
